/* Copyright (c) 2021, National University of Defense Technology. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef COO_MATRIX_H
#define COO_MATRIX_H

#include "operator.h"

namespace YHAMG
{

struct COO_Matrix : public Operator
{
	int ref;
	int size[2];
	int nnz;
	
	int* rowind;
	int* colind;
	double* values;

	COO_Matrix();
	COO_Matrix(int n, int m, int nnz, int* rowind, int* colind, double* values, int ref);
	COO_Matrix(const COO_Matrix& A);
	COO_Matrix(COO_Matrix&& A);
	~COO_Matrix();
	COO_Matrix& operator=(const COO_Matrix& A);
	COO_Matrix& operator=(COO_Matrix&& A);
	
	void Free();
	void Reference(const COO_Matrix& A);
	int InSize() const;
	int OutSize() const;
	void Apply(const Vector& x, const Vector& y) const;
};

}

#endif